import pymysql as sql
from flask import jsonify

connect = sql.Connect(
    host='rm-bp131vjnd9b99vmuq2o.mysql.rds.aliyuncs.com',
    port=3306,
    user='lin_432718',
    passwd='Lin817818',
    db='rail_traffic',
    charset='utf8'
)
cursor = connect.cursor()

# 修改监测间隙和时间，暂时还存在BUG
def modify(risk_id, gap, time1, time2):

    sql = "update riskpoint set gap='" + gap + "', checktime_1='" + time1 + \
          "', checktime_2= '" + time2 + "' WHERE risk_id='" + risk_id + "'"
    # print(sql)
    try:
        cursor.execute(sql)
        connect.commit()
    except:
        return jsonify(0)
    else:
        return jsonify(1)